package com.learn.kotlinlearndemolist.view

import android.content.Context
import android.view.Gravity
import com.learn.kotlinlearndemolist.R
import com.learn.kotlinlearndemolist.base.BaseDialog
import com.learn.kotlinlearndemolist.databinding.CustomDialogLayoutBinding

class CustomDialog(context: Context) : BaseDialog<CustomDialogLayoutBinding>(context) {

    override fun initView() {
        val window = window
        window?.setGravity(Gravity.TOP or Gravity.CENTER_HORIZONTAL)
        val layoutParams = window?.attributes
        layoutParams?.dimAmount = 0.3f
        layoutParams?.width = context.resources.getDimension(R.dimen.custom_dialog_width).toInt()
        layoutParams?.height = context.resources.getDimension(R.dimen.custom_dialog_height).toInt()
        layoutParams?.y = context.resources.getInteger(R.integer.dialog_margin_top)
        window?.attributes = layoutParams
        window?.setBackgroundDrawableResource(R.drawable.shape_toast_background)
        mBinding.btnClose.setOnClickListener { dismiss() }
        mBinding.btnSure.setOnClickListener { dismiss() }
    }

    override fun getResId(): Int {
        return R.layout.custom_dialog_layout
    }

}